package cn.edu.neusoft.maxingxin231.yuejian06.Adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Activity.ViewVideoActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.VideoBean;

public class VideoAdapter extends VideoBaseAdapter<VideoBean> {
   String id,video_img,video_name;


    public VideoAdapter(Context context, List<VideoBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        final VideoBean videoBean = items.get(position);
        if (videoBean == null)return;
        VideoViewHolder videoViewHolder = (VideoViewHolder)holder;
        videoViewHolder.v_2.setText(videoBean.getVideo_name());
        Picasso.with(context).load("http://10.0.2.2:80/yuejian14/public/static/video/video_img/"+items.get(position).getVideo_img()).into(videoViewHolder.v_1);

        videoViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("TEST", "onClick: ");
                Intent intent = new Intent(context,ViewVideoActivity.class);
                intent.putExtra("video_id",videoBean.getVideo_id());
                intent.putExtra("video_img",videoBean.getVideo_img());
                intent.putExtra("video_name",videoBean.getVideo_name());
                intent.putExtra("video_url",videoBean.getVideo_url());
                context.startActivity(intent);
            }
        });
    }
}
